﻿
Public Class cProveedores

    Private ldrProv As dsTercero.TER_PROVEEDORESRow
    Private lIFormaPago As cFormasPago
    Sub New(ByVal IdProveedor As String)
        Try
            Dim daProv As New dsTerceroTableAdapters.TER_PROVEEDORESTableAdapter
            Dim dtProv As dsTercero.TER_PROVEEDORESDataTable = daProv.GetDataByIdProveedor(IdProveedor)
            If dtProv.Rows.Count > 0 Then
                ldrProv = dtProv.Rows(0)
                lIFormaPago = New cFormasPago(ldrProv.IDFORMAPAGO)
            Else
                Throw New Exception("No existe proveedor para este id, favor verifique e intente de nuevo")
            End If
        Catch ex As Exception
            cError.SalvaError(ex, "Samuel")
            Throw ex
        End Try
    End Sub

    Public ReadOnly Property idProveedor() As String
        Get
            Return ldrProv.IDPROVEEDOR
        End Get
    End Property

    Public ReadOnly Property Cupo() As Double
        Get
            Return ldrProv.CUPO
        End Get
    End Property

    Public ReadOnly Property idFormaPago() As String
        Get
            Return ldrProv.IDFORMAPAGO
        End Get
    End Property

    Public ReadOnly Property iFormaPago() As cFormasPago
        Get
            Return lIFormaPago
        End Get
    End Property

    Public ReadOnly Property estado() As Char
        Get
            Return ldrProv.ESTADO
        End Get
    End Property

    Protected Overrides Sub Finalize()
        lIFormaPago = Nothing
        ldrProv = Nothing
    End Sub
End Class
